RightProjection

data class RightProjection<out L, out R>(val either: Either<L, R>)

Constructors

Link copied to clipboard
fun <out L, out R> RightProjection(either: Either<L, R>)

Functions

Link copied to clipboard
inline fun all(predicate: (R) -> Boolean): Boolean

Returns the result of applying the predicate to the value if this is Right or true if this is Left.

Link copied to clipboard
inline fun any(predicate: (R) -> Boolean): Boolean

Returns the result of applying the predicate to the value if this is Right or false if this is Left.

Link copied to clipboard
inline fun filter(predicate: (R) -> Boolean): Either<L, R>?

Returns the same Right if the predicate is satisfied for the value. Otherwise returns null.

Link copied to clipboard
inline fun <T> filterIsInstance(): Either<L, T>?

Returns the same Right casted to type T if it is T. Otherwise returns null.

Link copied to clipboard
inline fun <T> filterIsInstanceToOption(): Option<Either<L, T>>

Returns Some containing the same Right casted to type T if it is T. Otherwise returns None.

Link copied to clipboard
inline fun filterNot(predicate: (R) -> Boolean): Either<L, R>?

Returns the same Right if the predicate is not satisfied for the value. Otherwise returns null.

Link copied to clipboard
inline fun filterNotToOption(predicate: (R) -> Boolean): Option<Either<L, R>>

Returns Some containing the same Right if the predicate is not satisfied for the value. Otherwise returns None.

Link copied to clipboard
inline fun filterToOption(predicate: (R) -> Boolean): Option<Either<L, R>>

Returns Some containing the same Right if the predicate is satisfied for the value. Otherwise returns None.

Link copied to clipboard
inline fun forEach(action: (R) -> Unit)

Runs action if this is a Right. Returns Unit without any action if this is a Left.

Link copied to clipboard
fun get(): R

Gets value of this Right.

Link copied to clipboard
fun getOrNull(): R?

Gets value of this Right or null if this is Left.

Link copied to clipboard
inline fun <T> map(transform: (R) -> T): Either<L, T>

Maps value of this Right using transform.

Link copied to clipboard
inline fun none(predicate: (R) -> Boolean): Boolean

Returns false if the predicate is met by the value if this is Right or true otherwise.

Link copied to clipboard
fun toOption(): Option<R>

Returns a Some containing the Right value if it exists, or a None if this is a Left.

Properties

Link copied to clipboard
val either: Either<L, R>

Extensions

Link copied to clipboard
fun <L, R> RightProjection<L, R?>.filterNotNull(): Either<L, R>?

Returns the same Right if its value is not null. Otherwise returns null.

Link copied to clipboard
fun <L, R> RightProjection<L, R?>.filterNotNullToOption(): Option<Either<L, R>>

Returns Some containing the same Right if its value is not null. Otherwise returns None.

Link copied to clipboard
inline fun <L, R> RightProjection<L, R>.filterOrElse(predicate: (R) -> Boolean, zero: () -> L): Either<L, R>

Returns the same Right if the predicate is satisfied for the value, Left(zero) if the predicate is not satisfied for the value, or the same Left if this is Left.

Link copied to clipboard
inline fun <L, R, T> RightProjection<L, R>.flatMap(transform: (R) -> Either<L, T>): Either<L, T>

Maps value of this Right to a new Either using transform.

Link copied to clipboard
inline fun <L, R> RightProjection<L, R>.getOrElse(default: () -> R): R

Gets value of this Right or default value if this is Left.